/*
 * > /*
>  * INSANE - Interactive Structural Analysis Environment
>  *
>  * Copyright (C) 2003-2004
>  * Universidade Federal de Minas Gerais
>  * Escola de Engenharia
>  * Departamento de Engenharia de Estruturas
>  *
>  * Author's email :     insane@dees.ufmg.br
>  * Author's Website :   http://www.dees.ufmg.br/insane
>  *
>  * This program is free software; you can redistribute it and/or
>  * modify it under the terms of the GNU General Public License
>  * as published by the Free Software Foundation; either version 2
>  * of the License, or any later version.
>  *
>  * This program is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  * GNU General Public License for more details.
>  *
>  * You should have received a copy of the GNU General Public License
>  * along with this program; if not, write to the Free Software
>  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-
> 1307, USA.
 *
 */

package br.ufmg.dees.insane.ui.rich.learn.learn_view;


/**
 *
 * @author  krishna
 * @version
 */
public class TexMSFormatter extends MatrixSystemFormatter {
    
    /** Creates new HtmlMSFormatter */
    public TexMSFormatter(LearnInterface parent) {
        //msa = new MatrixStructuralAnalysis(parent.getModel().getDModel());
        //rows = msa.numberingAll();
    	cols = rows = 20;
        //A = new GMatrix(msa.addGlobalMatrix());
        //B = new GVector(msa.addGlobalVector());
        //X = new GVector(msa.solver());
        ATitle = "Stiffness";
        BTitle =  "Forces";
        XTitle = "Displacements";
        rowLabels = new String[rows];
        colLabels = new String[cols];
        for (int i = 0; i < rows; i++) {
            rowLabels[i] = new String("" + (i + 1));
        }
        colLabels = rowLabels;
    }
    
    public String format() {
        StringBuffer str = new StringBuffer("\\begin{eqnarray} \n");
        str.append("\\begin{array}{ccc} \n");
        str.append("\\left[ \n");
        str.append("\\begin{array}{");
        for(int j = 0; j < cols; j++) {
            str.append("c");
        }
        str.append("} \n");
        for (int i = 0; i < rows; i++) {
        	/*for(int j = 0; j < cols; j++) {
		if( j != (cols - 1)){
            	    str.append("~" + A.getElement(i,j) + "~ & ");
		} else {
            	    str.append("~" + A.getElement(i,j) + "~ ");
		}
            }*/
	    if( i != (rows - 1)){
                str.append("\\\\ \n");
	    } else {
                str.append("\n");
	    }
        }
        str.append("\\end{array} \n");
        str.append("\\right]& \n");
        str.append("~x~ \n");
        str.append("\\left\\{ \n");
        str.append("\\begin{array}{c} \n");
        /*for (int i = 0; i < rows; i++) {
	    if( i != (rows - 1)) {
                str.append("~" + X.getElement(i) + " \\\\ \n");
	    } else {
                str.append("~" + X.getElement(i) + " \n");
	    }
        }*/
	str.append("\\end{array}");
	str.append("\\right\\}& \n");
        str.append("~=~ \n");
	str.append("\\left\\{ \n");
        str.append("\\begin{array}{c} \n");
        /*for (int i = 0; i < rows; i++) {
	    if( i != (rows - 1)){
                str.append("~" + B.getElement(i) + " \\\\ \n");
	    } else {
                str.append("~" + B.getElement(i) + " \n");
	    }
        }*/
	str.append("\\end{array} \n");
	str.append("\\right\\} \n");
	str.append("\\end{array} \n");
	str.append("\\end{eqnarray} \n");
        return str.toString();
    }
    
}
